// pages/shopping/shoplist/shoplist.js
const app = getApp()
const $ = app.globalData
Page({
  data: {
	  salemodelid:1,
	  page:1,
	  goodslist:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
	console.log(options)
	var that = this
	var salemodelid = options.id?options.id:1
	that.setData({
		salemodelid:salemodelid
	})
	that.getgoods()
  },
  onShow: function () {

  },
  clickGoods:function(e){
	  var thisid = e.currentTarget.dataset.id
	  wx.navigateTo({
	  	url:"/pages/shopping/business/business?id="+thisid
	  })
  },
  loadgengduo:function(){
	  var that = this
	  that.setData({
		  page:that.data.page+1
	  })
	  that.getgoods()
  },
  pingtaigoods:function(e){
	   var thisid = e.currentTarget.dataset.id
	  wx.navigateTo({
	  	url:"/pages/shopping/details/details?id="+thisid+"&goodslib=0"
	  })
  },
  getgoods:function(){
	  var that = this
	  var goodslist = that.data.goodslist
	  wx.request({
	  	url:$.AdminUrl+"/YApi/getSalemodel",
		data:{
			salemodelid:that.data.salemodelid,
			page:that.data.page
		},
		success:function(data){
			var all = data.data.obj
			goodslist = goodslist.concat(all)
			that.setData({
				loadmore:data.data.obj.length>=10?true:false,
				goodslist:goodslist
			})
		}
	  })
  }
})